package com.yxym.interface_;

public class InterfacePolyArr {
    public static void main(String[] args) {
        //多态数组 -》接口类型数组
        Usb[] usbs = new Usb[2];
        usbs[0] = new Iphone();
        usbs[1] = new Camera();
        for (int i = 0; i < usbs.length; i++) {
            usbs[i].Study();//动态绑定
            if (usbs[i] instanceof  Camera){//判断运行类型
                ((Camera) usbs[i]).pa();
            }
        }
    }
}

interface Usb{
    public void Study();
}

class Iphone implements Usb{
    public void call(){
        System.out.println("打电话...");
    }

    @Override
    public void Study() {
        System.out.println("手机可以学习...");
    }
}
class Camera implements Usb{
    public void pa(){
        System.out.println("拍照...");
    }

    @Override
    public void Study() {
        System.out.println("相机可以学习拍照000.");

    }
}